import 'package:flutter/material.dart';
import '../pages/tabs.dart';
import '../pages/search.dart';
import '../pages/users/login.dart';
import '../pages/users/register.dart';

import '../pages/AppBarIconPage.dart';
import '../pages/TabBar/TabBars.dart';
import '../pages/TabBar/TabBarPage.dart';
import '../pages/TabBar/TabBarController.dart';
import '../pages/buttonPage.dart';
import '../pages/DrawerPage.dart';
import '../pages/FormPage.dart';
import '../pages/DatePickerPage.dart';
import '../pages/swiperPage.dart';
import '../pages/AlertPage.dart';
import '../pages/HttpPage.dart';
import '../pages/Scroll.dart';
import '../pages/WebViewPage.dart';
import '../pages/api/DevicePage.dart';
import '../pages/api/LocationPage.dart';
import '../pages/api/ImagePage.dart';
import '../pages/api/VideoPage.dart';
import '../pages/api/CheckNetworkPage.dart';
import '../pages/api/StoragePage.dart';
import '../pages/api/ScanCodePage.dart';
import '../pages/api/UpgradeAppPage.dart';
import '../pages/api/UrlLauncherPage.dart';

//配置路由
final routes = {
  '/': (context) => Tabs(),
  '/search': (context, {arguments}) => SearchPage(arguments: arguments),
  '/login': (context) => LoginPage(),
  '/register': (context) => RegisterPage(),
  '/AppBarIconPage': (context) => AppBarIconPage(),
  '/TabBarPage': (context) => TabBarPage(),
  '/TabBars': (context) => TabBars(),
  '/TabBarController': (context) => TabBarControllerPage(),
  '/DrawerPage': (context) => DrawerPage(),
  '/ButtonPage': (context) => ButtonPage(),
  '/DatePickerPage': (context) => DatePickerPage(),
  '/FormPage': (context) => FormPage(),
  '/AlertPage': (context) => AlertPage(),
  '/HttpPage': (context) => HttpPage(),
  '/swiperPage': (context) => SwiperPage(),
  '/ScrollPage': (context) => ScrollPage(),
  '/WebViewPage': (context) => WebViewPage(),
  '/DevicePage': (context) => DevicePage(),
  '/LocationPage': (context) => LocationPage(),
  '/ImagePage': (context) => ImagePage(),
  '/VideoPage': (context) => VideoPage(),
  '/CheckNetworkPage': (context) => CheckNetworkPage(),
  '/StoragePage': (context) => StoragePage(),
  '/ScanCodePage': (context) => ScanCodePage(),
  '/UpgradeAppPage': (context) => UpgradeAppPage(),
  '/UrlLauncherPage': (context) => UrlLauncherPage(),
};

//固定写法
var onGenerateRoute = (RouteSettings settings) {
  // 统一处理
  final String name = settings.name;
  print(settings.name);
  final Function pageContentBuilder = routes[name];
  if (pageContentBuilder != null) {
    if (settings.arguments != null) {
      final Route route = MaterialPageRoute(
          builder: (context) =>
              pageContentBuilder(context, arguments: settings.arguments));
      return route;
    } else {
      final Route route =
          MaterialPageRoute(builder: (context) => pageContentBuilder(context));
      return route;
    }
  }
};
